home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
-
-
-
- A
- Comparison
- of
-
-
- ===========================================================
- MM MM IIIIIII CCCC RRRRRR OOO CCCC
- M M M M I C C R R O O C C
- M M M I C R R O O C
- M M I C RRRRRR O O ----- C
- M M I C R R O O C
- M M I C C R R O O C C
- M M IIIIIII CCCC R R OOO CCCC
- ===========================================================
-
- A N D
-
- ===========================================================
- SSSSS MM MM A L L CCCC
- S S M M M M A A L L C C
- S M M M A A L L C
- SSSSS M M A A L L ----- C
- S M M AAAAAAA L L C
- S S M M A A L L C C
- SSSSS M M A A LLLLLLL LLLLLLL CCCC
- ===========================================================
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Copyright 1990-1994 Dave Dunfield
- All rights reserved
- MICRO-C .vs. SMALL-C Page: 1
-
-
- 1. INTRODUCTION
-
- The most common reaction of people hearing about DDS MICRO-C for
- the first time is something like "Humph... Another version of the old
- SMALL-C compiler". This couldn't be further from the truth.
-
- MICRO-C IS NOT SMALL-C!!!
-
- MICRO-C is a completely new implementation of a 'C' compiler
- suitable for use on very small systems. It offers several advantages
- over SMALL-C:
-
- - It was designed from the ground up to be easily portable to
- different processors & computer platforms. Code generators are
- available for 8080, 8051, 80x86, 8096, 6809, 68HC11 and 68HC16
- cpu's, and an entire section of the manual is devoted to porting
- the compiler.
-
- Although SMALL-C claims to be easily portable, much of it's
- arcitecture is oriented toward the original 8080 processor. For an
- example of how this affects the compiler, compare the code
- generated by the 8086 version of SMALL-C to reference stack (auto)
- variables to that produced by MICRO-C.
-
- - It is a more complete implementation of the 'C' language, see the
- features comparison later in this document.
-
- - It produces faster, more compact code. See the benchmark results
- later in this document.
-
- - MICRO-C employs a fully tokenized parser, allowing statement
- analysis to be performed on 16 bit "tokens" instead of text
- strings as is done in SMALL-C. This results in MUCH faster
- compilation.
-
- - Although it is higher in functionality than SMALL-C, the MICRO-C
- compiler is much smaller than SMALL-C (Nearly half the size). This
- allows it to run on very small computer systems.
-
- 2. DETAILED COMPARISON OF COMPILERS
-
- The following pages contain a detailed comparison of the SMALL-C
- version 2 compiler, and MICRO-C.
- MICRO-C .vs. SMALL-C Page: 2
-
-
- 2.1 'C' Implementation
- = Data Types ===========+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
- int | Yes | Yes | Yes |
- char | Yes | Yes | Yes |
- unsigned int | No | No | Yes |
- unsigned char | No | No | Yes |
- pointers | Yes | Yes | Yes |
- pointers to pointers | No | No | Yes |
- structs & unions | No | No | Yes |
- Single dimension arrays | Yes | Yes | Yes |
- Multi dimension arrays | No | No | Yes |
- Arrays of pointers | No | No | Yes |
- Arrays of structs | No | No | Yes |
- Typecast | No | No | Yes |
- sizeof | No | No | Yes |
- Static globals & locals | No | No | Yes |
- = Control Structures ===+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
- if/else | Yes | Yes | Yes |
- while | Yes | Yes | Yes |
- do/while | No | Yes | Yes |
- for | No | Yes | Yes |
- switch/case | No | Yes | Yes |
- goto | No | Yes | Yes |
- Conditional Expressions | No | Yes | Yes |
- Inline assembler | Yes | Yes | Yes |
- = Pre-Processor ========+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
- #define (basic) | Yes | Yes | Yes |
- #define (Parameterized) | No | No | Yes |
- #define (Multi-line) | No | No | Yes |
- #undef | No | No | Yes |
- #include (single level) | Yes | Yes | Yes |
- #include (nested) | No | Yes | Yes |
- #ifdef/#ifndef | No | Yes | Yes |
- = Misc features ========+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
- Optimization | No | Yes | Yes |
- Multiple memory models | No | No | Yes |
- Make/touch utility | No | No | Yes |
- Source linker | No | No | Yes |
- 68HC08 code generator | No | No | Yes |
- 6809 code generator | No | No | Yes |
- 68HC11 code generator | No | No | Yes |
- 68HC16 code generator | No | No | Yes |
- 8080 code generator | Yes | Yes | Yes |
- 8051 code generator | No | No | Yes |
- 8086 code generator | No | Yes | Yes |
- 8096 code generator | No | No | Yes |
- Complete standard lib | No | Yes | Yes |
- Interrupt serial I/O | No | No | Yes |
- Windowing library | No | No | Yes |
- TSR support | No | No | Yes |
- MICRO-C .vs. SMALL-C Page: 3
-
-
- 2.2 Generated code quality
-
- To test the actual performace of code generated by MICRO-C
- against code generated by SMALL-C, I used this "Sieve of
- Eratosthenes" prime number generator program, taken from the BYTE
- benchmarks:
-
-
-
-
-
- /*
- * The classic "Sieve of Eratosthenes" prime number program.
- * from BYTE, January 1983.
- */
- #include <stdio.h>
- #include "timer.c" /* The timer subroutines */
-
- #define SIZE 8190
- #define LOOP 100
- #define TRUE 1
- #define FALSE 0
-
- char flags [SIZE + 1];
-
- main()
- {
- int i, prime, k, count, iter;
-
- printf("BYTE Sieve Benchmark - %d iterations\n",LOOP);
-
- /* Start timer and execute loop */
- startimer(timestamp);
- for(iter = 1; iter <= LOOP; ++iter) {
- count = 0; /* prime counter */
- for(i = 0; i <= SIZE; ++i) /* set all flags true */
- flags [i] = TRUE;
- for(i = 0; i <= SIZE; ++i) {
- if(flags [i]) { /* found a prime */
- prime = i + i + 3; /* twice index + 3 */
- /* printf ("\n%d", prime); */
- for(k = i + prime; k <= SIZE; k+= prime)
- flags [k] = FALSE; /* kill all multiple */
- ++count; } } } /* primes found */
- elapsed(timestamp); /* Calculate time taken */
-
- /* Report results */
- printf("%d primes.\n\n", count); /* primes found on 100th pass */
- printf("Elapsed time: %02d:%02d:%02d.%02d\n",
- timestamp[1], timestamp[0], timestamp[3], timestamp[2]);
- }
- MICRO-C .vs. SMALL-C Page: 4
-
-
- 2.3 Speed of compilation
-
- To show the relative compilation times, I wrote this simple
- MICRO-C program, using the timing routines shown below, to execute
- the compilers & report the time taken:
-
-
-
-
-
- #include <stdio.h>
- #include "timer.c" /* The timer subroutines */
-
- main()
- {
- startimer(timestamp);
- system("CC SIEVE"); /* Execute the SMALL-C compiler */
- elapsed(timestamp);
- printf("Elapsed time: %02d:%02d:%02d.%02d\n\n",
- timestamp[1], timestamp[0], timestamp[3], timestamp[2]);
-
- startimer(timestamp);
- system("MCC SIEVE.C SIEVE.ASM");/* Execute the MICRO-C compiler */
- elapsed(timestamp);
- printf("Elapsed time: %02d:%02d:%02d.%02d\n",
- timestamp[1], timestamp[0], timestamp[3], timestamp[2]);
- }
-
- NOTE: The results from the above program will include the time
- taken to load the compilers. To minimize this, all tests were run
- from a RAMdisk. This eliminates disk seek time, and reduces load
- time to the speed of a memory to memory copy.
- MICRO-C .vs. SMALL-C Page: 5
-
-
- 2.4 Timing the tests
-
- These subroutines were used to time the programs, using the
- MS-DOS internal clock which has a resolution of 1/100 of a second:
-
-
-
-
-
- char timestamp[4]; /* Stores initial timestamp */
-
- /*
- * Record system time for later calculation
- */
- startimer() asm
- {
- MOV AH,2CH ; Get time function
- INT 21H ; Ask DOS
- MOV SI,4[BP] ; Get pointer to timestamp
- MOV [SI],CX ; Record hours & minites
- MOV 2[SI],DX ; Record seconds & hundreds
- }
-
- /*
- * Calculate elapsed time since timestamp recorded
- */
- elapsed() asm
- {
- MOV AH,2CH ; Get time function
- INT 21H ; Ask DOS
- MOV SI,4[BP] ; Pointer to timestamp
- SUB DL,2[SI] ; Convert 100ths
- JNC ELAP1 ; No borrow
- ADD DL,100 ; Re-adjust
- DEC DH ; Reduce seconds
- ELAP1: MOV 2[SI],DL ; Save elapsed hundreds
- SUB DH,3[SI] ; Convert seconds
- JNS ELAP2 ; No borrow
- ADD DH,60 ; Re-adjust
- DEC CL ; Reduce minites
- ELAP2: MOV 3[SI],DH ; Save elapsed seconds
- SUB CL,[SI] ; Convert minites
- JNS ELAP3 ; No borrow
- ADD CL,60 ; Re-adjust
- DEC CH ; Adjust hours
- ELAP3: MOV [SI],CL ; Save elapsed minites
- SUB CH,1[SI] ; Convert hours
- MOV 1[SI],CH ; Save elapsed hours
- }
- MICRO-C .vs. SMALL-C Page: 6
-
-
- 2.5 Test results
-
- After compiling the programs, I ran the various tests on a
- standard 8-Mhz IBM PC/AT, with these results:
-
- E:\>dir
-
- Volume in drive E is VDISK V3.3
- Directory of E:\
-
- CC EXE 40626 4-27-93 /* SMALL-C compiler */
- MCC COM 24154 4-27-93 /* MICRO-C compiler */
- TIMER C 1094 4-27-93 /* The timer subroutines */
- TIMECOMP C 527 4-27-93 /* The compiler timer */
- SIEVE C 1149 4-27-93 /* The test program */
- SIEVE-S EXE 16946 4-27-93 /* SMALL-C produced this */
- SIEVE-M COM 1744 4-27-93 /* MICRO-C produced this */
- TIMECOMP COM 1908 4-27-93 /* Executable compiler timer */
- 8 File(s) 430080 bytes free
-
- E:\>sieve-s /* The SMALL-C version: 1 min, 28.98 secs */
- BYTE Sieve Benchmark - 100 iterations
- 1899 primes.
-
- Elapsed time: 00:01:28.98
-
- E:\>sieve-m /* The MICRO-C version: 0 min, 40.43 secs */
- BYTE Sieve Benchmark - 100 iterations
- 1899 primes.
-
- Elapsed time: 00:00:40.43
-
- E:\>
-
- **NOTE: Before running TIMECOMP, I created a "generic" STDIO.H
- file which was suitable for both compilers.
-
- E:\>timecomp /* Times to compile the program */
- Small-C Compiler, Version 2.1, (Rev. 75)
- Copyright 1982, 1983, 1985 J. E. Hendrix
- Elapsed time: 00:00:04.72 /* SMALL-C 4.72 secs */
-
- MICRO-C Compiler
- Copyright 1988-1993 Dave Dunfield
- All rights reserved.
- Elapsed time: 00:00:01.15 /* MICRO-C 1.15 secs */
-
- E:\>
- MICRO-C .vs. SMALL-C Page: 7
-
-
- 3. OTHER ADVANTAGES OF MICRO-C
-
- In addition to being a superiour and more portable compiler, The
- MICRO-C package also offers these advantages:
-
- 3.1 Utilities
-
- MICRO-C Comes with the following utilities (all with complete
- MICRO-C source code):
-
- CC - Command Coordinator, combines pre-processor, compiler,
- optimizer, assembler and linker into a single command.
- Command line parameters allow very flexible operation.
-
- MAKE - Automates building of larger (multi module) programs.
-
- TOUCH - Set timestamp of file to current or specified date.
- (Used with MAKEs dependancy checking)
-
- SLINK - Source LINKer, Allows pre-compiled (assembler) source to
- be kept in a library and included as needed to resolve
- external references. Useful when MICRO-C is used as cross
- compiler for systems not supporting an object linker.
-
- SLIB - Utility for updating and maintaining a source library.
-
- SINDEX - Automatically indexes a source library for use by SLINK.
-
- SCONVERT- Converts assembly language source for use by SLINK.
-
- EXE2BIN - Converts MS-DOS EXE files to a binary image, useful for
- users of later versions of DOS which no longer include
- this utility.
-
- MCP - The MICRO-C Pre-processor
-
- MCC - The MICRO-C Compiler
-
- MCO - The MICRO-C Optimizer
- MICRO-C .vs. SMALL-C Page: 8
-
-
- 3.2 Example Programs
-
- MICRO-C comes with the following archives of example programs
- (all with complete MICRO-C source code):
-
- CUTIL: 'C' utilities & related programs
- CCREF - 'C' source cross referencing program
- COMEXT - Extract comments from 'C' sources
- CVTCOM - Convert C++ '//' comments to '/* */'
- OBSCURE - Make 'C' program un-readable (but it still compiles)
- PPC - Pretty Printer for 'C' (source formatter)
- SHELL - Command line / interactive shell program
-
- DOSUTIL: DOS utilities
- ANYFILE - Set ERRORLEVEL on file matching patterns
- BOOTMENU - "boot" menu, allowing different AUTOEXEC and CONFIG files
- CALC - A TSR programmers (HEX/DECIMAL) calculator
- CAN - Automatically append arguments to ".COM" files
- CHAINSAW - Remove an entire directory tree
- CHATTR - Change attributes of DOS files
- CMOS - Read/Write/Verify CMOS RAM from/to/with disk file
- COMCHK - Checksum .COM file every time it runs
- CSET - TSR map of IBM PC character set
- DIFF - Displays differences between text files
- DUMP - Hex/Octal/ASCII file dump utility
- EQUIP - Display hardware installed in PC
- GREP - Like unix "GREP" search utility
- HEM - Hardware Exception Monitor TSR to trap unexpected ints
- HEXED - Screen oriented Hex file editor
- LZC - Laser commander TSR to control HP compatible printers
- MEMSAVE - Saves memory image to file
- MTERM - Tiny (10k!) TSR ANSI terminal with XMODEM
- OFF - Screen saver
- PARK - Configurable hard disk parking utility
- PCD - PC "countdown" timer
- RETAB - Retabulates files to different TAB stops
- SCRUB - Utility for cleaning floppy drives
- SHOWEXE - Displays information about a .EXE file
- SIZE - Show file(s) exact size and number of lines
- STUFF - Stuffs keycodes into the keyboard buffer
- TFB - TSR File Browser
- TIMEIT - Time execution of other DOS commands
- TR - Like unix TR (translate) command
- TYPE4 - Display files with tabs at 4 character intervals
- VALIDATE - PD ver of McAfee's validate. Verify files with two CRC's
-
- LAPTALK: A small (20K) but powerful comms pogram
- LAPTALK - A terminal program with script interpreter
- XMODEM - External file transfer program
-
- MICROCAD: A VGA drawing program
- MICROCAD - Mouse based drawing program
- MCPRINT - Prints MICROCAD files on Laserjet or Epson printers
- MCDRAW - Minimal routines to display MICROCAD file in other pgms
- FE - Font Editor
- MICRO-C .vs. SMALL-C Page: 9
-
-
- MISC: Other misc. programs
- ASM86 - 8086 assembler
- BASIC - A simple BASIC interpreter
- BIGNUM - Add/Sub/Mul/Div/Mod very large numbers
- BITARRAY - Example of using an array of bits.
- BJ - Blackjack (21) game
- BYTESWAP - Example of using UNION's
- CASTLE - A large text based "adventure" game
- FIBO - Calculates a fibonacci series
- FORTUNE - A "fortune cookie" - Displays random quotation
- HANOI - Solves "towers of hanoi" on screen
- HELLO - Standard 'C' demo program
- HFTEXT - Text compressor using Huffman encoding
- KIDSMENU - Colorful mouse/keyboard based menuing system for kids
- KMEDIT - Editor for kids menu database
- LONGCALC - A "long" (32 BIT) desk calculator
- MDCFS - Minimal DOS compatible File System
- OBFUSC - Example of how NOT to write 'C'
- PRIME - Calculates prime numbers
- PRIME1 - Another prime number calculator
- PTR2FUNC - Demo's use of pointers to functions
- RAIN - Makes characters "fall" off the screen
- RDC - Another text compression program
- RLTEXT - Text compression using run length encoding
- ROBOFACE - Draws a "robot face"
- SELFDUP - A self-replicating 'C' program!
- TEXTNUM - Converts numbers to text equivalent
- TTT3D - 3 dimensional tic-tac-toe
- WINDEMO - Demonstrates MICRO-C windowing
-
-
-
- MICRO-C .vs. SMALL-C
-
- TABLE OF CONTENTS
-
-
- Page
-
- 1. INTRODUCTION 1
-
-
- 2. DETAILED COMPARISON OF COMPILERS 1
-
- 2.1 'C' Implementation 2
- 2.2 Generated code quality 3
- 2.3 Speed of compilation 4
- 2.4 Timing the tests 5
- 2.5 Test results 6
-
- 3. OTHER ADVANTAGES OF MICRO-C 7
-
- 3.1 Utilities 7
- 3.2 Example Programs 8
-